﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using OFDParserLibrary;
namespace OFDParserLibrary_Test
{
    public partial class Form1 : Form
    {
        OFDParser ofdParser = new OFDParser();
        public Form1()
        {
            InitializeComponent();
        }

        private void btn_call_Click(object sender, EventArgs e)
        {
            string selectedFileFullName = string.Empty;
            using (OpenFileDialog of = new OpenFileDialog())
            {
                of.Title = "选择ofd版式发票文件";
                of.Filter = "|*.ofd";
                if (DialogResult.OK == of.ShowDialog())
                {
                    txt_filename.Text = of.FileName;
                    selectedFileFullName = of.FileName;
                }
                else //取消选择ofd文件则不进行解析直接退出
                {
                    return;
                }
            }
            if (string.IsNullOrEmpty(selectedFileFullName))
            {
                MessageBox.Show("请选择要解析的ofd版式发票文件");
                return;
            }
           
            string result = cbx_save.Checked? ofdParser.Parse(selectedFileFullName)
                : ofdParser.Parse(selectedFileFullName, false);
            rtxt_output.Clear();
            rtxt_output.Text = result;   
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            lb_version.Text = ofdParser.Version;
        }
    }
}
